<?php 
$start = 0;
$offset = 20;
?>
<script type="text/javascript">
var limit = {
		start : parseInt(0)	
}

function failure(message){
	box_failure = new LightFace({ 
			title: 'Failure', 
			width : 300,
			content: "<div class='failure'>"+message+"</div>"
			,
			buttons: [{ title: 'Cancel', event: function() { this.close();}, color: 'green'}]
		});
		box_failure.open();		
}
function box_message(titleMessage,message){
	box_message = new LightFace({ 
			title: titleMessage, 
			width : 300,
			content: "<div class='message'>"+message+"</div>"
			,
			buttons: [{ title: 'Close', event: function() { this.close();}, color: 'green'}]
		});
		box_message.open();
}




function showScore(){
		
	var myRequest = new Request({
		url: '<?php echo base_url()."sas/ajax_score_show/"?>',
		method: 'post',
		onSuccess : function(responseText){
			$('score').fade('hide');
			$('score').fade(1);
			//$('score').set('tween', {transition: Fx.Transitions.Elastic.easeIn});
			$('score').innerHTML = responseText;
		}
	}).send();

}

function cekSubject() {
	//alert('<?php echo get_cookie('subject')?>');
}

function addsubject(id) {
	//var id = '<?php echo get_cookie('subject')?>';
	//alert(id);
}

function search_pages(form, evt){
	var perpage = {
			page : parseInt($(document.forms['viewperpage']).perpage.value)
		}
	new Event(evt).stop();
	var temp = {
		src : $(document.forms['search']).src.value
	}
	form = $(form);
		form.set('send', {
			url:'<?php echo site_url(array('dash','lesson_show')) ?>'+'/'+limit.start+'/'+perpage.page+'/'+temp.src,
			method :'post',
		 	onSuccess: function(responseText, responseXML){
				showLesson();
			},
			onComplete: function(){
				
			},
			onFailure: function(xhr){
				alert("failure");
			}
		});
		form.send();
	return false;
}

function nextl(val){
	var perpage = {
			page : parseInt($(document.forms['viewperpage']).perpage.value)
		}
	var temp = {
			src : $(document.forms['search']).src.value
		}
	var source,next;
	source = limit.start;
	limit.start = source+perpage.page;
	var myRequest = new Request({
		url: '<?php echo base_url()."dash/lesson_show/"?>'+'/'+limit.start+'/'+perpage.page+'/'+temp.src,
		method: 'post',
		onSuccess : function(responseText){
			$('lesson_show').innerHTML = responseText;
		}
	}).send();
}

function prevl(){
	var perpage = {
			page : parseInt($(document.forms['viewperpage']).perpage.value)
		}
	var temp = {
			src : $(document.forms['search']).src.value
		}
	var source,next;
	source = limit.start;
	if(source>=perpage.page){
		limit.start = source-perpage.page;
		var myRequest = new Request({
			url: '<?php echo base_url()."dash/lesson_show/"?>'+'/'+limit.start+'/'+perpage.page+'/'+temp.src,
			method: 'post',
			onSuccess : function(responseText){
				$('lesson_show').innerHTML = responseText;
			}
		}).send();
	} else {
		return false;
	}
}

function score_active(form, evt, val){
	var msg = "";
	new Event(evt).stop();
	form = $(form);
		form.set('send', {
			url:'<?php echo site_url(array('sas','score_act'))?>'+'/'+val,
			method :'post',
		 	onSuccess: function(responseText, responseXML){	
			 	box_delete.close();
			 	showScore();
			},
			onComplete: function(){
				
			},
			onFailure: function(xhr){
				var message = "Failed to Active";
				failure(message);
			}
		});
		form.send();
	return false;
}
function active(val){
	box_delete = new LightFace({
		buttons: [
			{ title: 'Active', event: function() { score_active(this, event, val); }, color: 'green' },
			{ title: 'Cancel', event: function() { this.close(); } }
		],
		title: 'Delete',
		content: 'Are you sure you want to Active this file'
	}).open();
}

function score_deactive(form, evt, val){
	var msg = "";
	new Event(evt).stop();
	form = $(form);
		form.set('send', {
			url:'<?php echo site_url(array('sas','score_deact'))?>'+'/'+val,
			method :'post',
		 	onSuccess: function(responseText, responseXML){	
			 	box_delete.close();
			 	showScore();
			},
			osnComplete: function(){
				
			},
			onFailure: function(xhr){
				var message = "Failed to Deactive";
				failure(message);
			}
		});
		form.send();
	return false;
}
function deactive(val){
	box_delete = new LightFace({
		buttons: [
			{ title: 'Deactive', event: function() { score_deactive(this, event, val); }, color: 'green' },
			{ title: 'Cancel', event: function() { this.close(); } }
		],
		title: 'Delete',
		content: 'Are you sure you want to Deactive this file'
	}).open();
}

function score_corected(form, evt, val){
	var msg = "";
	new Event(evt).stop();
	form = $(form);
		form.set('send', {
			url:'<?php echo site_url(array('sas','score_corected'))?>'+'/'+val,
			method :'post',
		 	onSuccess: function(responseText, responseXML){	
			 	box_delete.close();
			 	showScore();
			},
			osnComplete: function(){
				
			},
			onFailure: function(xhr){
				var message = "Failed to Corected";
				failure(message);
			}
		});
		form.send();
	return false;
}

function corected(val){
	box_delete = new LightFace({
		buttons: [
			{ title: 'Corected', event: function() { score_corected(this, event, val); }, color: 'green' },
			{ title: 'Cancel', event: function() { this.close(); } }
		],
		title: 'Delete',
		content: 'Are you sure you want to Deactive this file'
	}).open();
}

window.addEvent('domready',function(){
    showScore();
    //cekSubject();
});
</script>
<table width="80%" border="0" align="left" cellpadding="3" cellspacing="0" class="table-box bg-trans">
  <tr class="capitalize bold font-size-16">
    <td>name</td>
    <td>class</td>
    <td>subject</td>
    <td>score</td>
    <td width="18%">posted</td>
    <td width="20%">config</td>
  </tr>
  <tr><td colspan="6"><hr size="1" color="#CCCCCC" width="100%" /></td></tr>
<tbody id="score"></tbody>
</table>